package com.example.controller.adm;

import java.util.Arrays;
import java.util.Date;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.vo.ResultVo;
import com.github.pagehelper.PageInfo;
import com.example.pojo.VehicleRecord;
import com.example.service.IVehicleRecordService;
import io.swagger.annotations.Api;
/**
 * <p>
 * 车辆使用记录表 前端控制器
 * </p>
 *
 * @author wsl
 * @since 2022-05-19
 */
@RestController
@RequestMapping("/vehicleRecord")
@Api(tags = "车辆使用记录表",value = "")
@CrossOrigin(allowCredentials = "true")
public class VehicleRecordController {

    @Autowired
    private IVehicleRecordService vehicleRecordService;

    @ApiOperation(value = "查询车辆使用记录表")
    @GetMapping("/query")
    public ResultVo queryVehicleRecordStatus(String empName) {
        return vehicleRecordService.queryVehicleRecordStatus(empName);
    }


    @ApiOperation(value = "新增车辆通过记录")
    @PostMapping("/add")
    public ResultVo insertVehicleRecord(@RequestBody VehicleRecord vehicleRecord){
        if (vehicleRecordService.save(vehicleRecord)) {
            return ResultVo.success("成功");
        }
        return  ResultVo.error("失败");
    }

    @ApiOperation(value = "修改车辆使用记录表")
    @PutMapping("/update")
    public ResultVo updateVehicleRecord(@RequestBody VehicleRecord vehicleRecord) {
        if (vehicleRecordService.updateById(vehicleRecord)) {
            return ResultVo.success("修改成功。");
        }
        return ResultVo.error("修改失败!");
    }
//
//    @ApiOperation(value = "删除车辆使用记录表")
//    @DeleteMapping("/delete")
//    public ResultVo deleteVehicleRecord(Integer[] ids){
//        if(vehicleRecordService.removeByIds(Arrays.asList(ids))){
//            return ResultVo.ok();
//        }
//        return ResultVo.error();
//    }
}
